<?php
class Widget_GoogleCalendar_Decorator
{
  const TEMPLATE = "WidgetGoogleCalendar.html";
  
  protected
    $calendar,
    $twig;
  
  public function __construct(Widget_GoogleCalendar_Calendar $cal)
  {
    $this->calendar = $cal;
    $this->twig     = Framework::Twig();
    $this->twig->addExtension(new Widget_GoogleCalendar_TwigExtension());
  }
  
  public function render($variables = null)
  {
    $template = $this->twig->loadTemplate(self::TEMPLATE);
    $template->display(array_merge((array) $variables, array('events' => $this->calendar->getEvents())));
  }
}